/**
 * Copyright 2018-2020 Streamlit Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@import "src/assets/css/variables";
@import "src/assets/css/mixins";

.reportview-container {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: stretch;
  align-content: flex-start;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;

  &.--wide {
    .main .block-container {
      min-width: auto;
      max-width: initial;
    }
  }

  .main {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: auto;
    align-items: center;

    &:focus {
      outline: none;
    }

    .block-container {
      flex: 1;
      max-width: $content-max-width;
      width: 100%;
      padding: $top-margin 1rem $bottom-margin 1rem;
      box-sizing: border-box;

      @media (max-width: 746px) {
        min-width: 0;
      }
    }

    footer {
      color: $gray-500;
      flex: 0;
      font-size: $font-size-sm;
      max-width: $content-max-width;
      padding: 0.5rem 1rem;
      width: 100%;

      a {
        color: $gray-500;
        transition: color 300ms;
      }

      &:hover {
        color: $gray;
      }

      &:hover a {
        color: $gray-dark;
      }

      a:hover {
        text-decoration: underline;
      }
    }
  }

  .element-container {
    @include element-margin-bottom;

    display: flex;
    flex-direction: column;
    // Allows to have absolutely-positioned nodes inside report elements, like
    // floating buttons.
    position: relative;

    &:hover {
      .overlayBtn {
        opacity: $overlayBtn-opacity-visible;
      }
    }

    .overlayBtn {
      opacity: 0;
      padding: $m1-2-font-size-sm/2 $m1-2-font-size-sm;
      position: absolute;
      right: -$overlayBtn-width;
      top: -0.375rem; // Align with Vega-Lite button.
      height: $overlayBtn-height;
      width: $overlayBtn-width;
      transition: opacity 300ms;
      z-index: 99;
      border: none;
      background: none;
      color: $black;
      border-radius: $btn-border-radius;

      &:active,
      &:focus,
      &:hover {
        opacity: $overlayBtn-opacity-active;
        outline: none;
      }
    }
  }

  .stale-element {
    opacity: 0.33;
    transition: opacity 1s ease-in 0.5s;
  }

  .stHidden {
    margin-bottom: 0;
  }

  h1,
  h2,
  h3 {
    // Use rem so we can remove it when first child, knowing that the
    // element-container above always adds 1rem.
    margin: 1.5rem 0 0.5rem 0;
    // Set padding in em-units to give it some adjustment that is proportional
    // to font size.
    padding: 0.5em 0 0.25em;
    // Set to 1 so it looks nice when wrapped.
    line-height: 1;
  }

  h4,
  h5,
  h6 {
    margin: 1rem 0 0 0;
    padding: 0.5em 0 0.25em;
    line-height: 1;
  }

  h1:first-child,
  h2:first-child,
  h3:first-child {
    margin-top: 0.5rem;
  }

  h4:first-child,
  h5:first-child,
  h6:first-child {
    margin-top: 0;
  }

  h1 {
    font-weight: 700;
    font-size: 2.25rem;
  }

  h2 {
    font-weight: 400;
    font-size: 1.75rem;
  }

  h3 {
    font-weight: 500;
    font-size: 1.25rem;
  }

  h4 {
    font-weight: 600;
    font-size: 1rem;
  }

  h5 {
    font-weight: 900;
    font-size: 0.8rem;
  }

  h6 {
    font-weight: 300;
    font-size: 0.8rem;
  }

  p,
  ul,
  ol,
  dl {
    @include element-margin-bottom;

    padding: 0;
    font-size: 1rem;
    font-weight: 400;
  }

  li {
    margin: 0.2em 0 0.2em 1.2em;
    padding: 0 0 0 0.6em;
    font-size: 1rem;
  }

  dt {
    font-weight: 600;
    margin: 1em 0 0.2em 0;
    padding: 0;
    font-size: 1rem;
  }

  dd {
    margin: 0 0 0.2em 1.2em;
    font-size: 1rem;
  }

  samp,
  blockquote {
    margin: 1em 0 1em -1px;
    padding: 0 0 0 1.2em;
    font-size: 1rem;
    border-left: 1px solid $gray-light;
  }

  hr {
    border: none;
    border-bottom: 1px solid $gray-light;
    margin: 2em 0;
    padding: 0;
  }
}

.streamlit-wide .reportview-container .element-container {
  .overlayBtn {
    right: 0;
    top: 0;
    background: #fff;
  }
}

body.embedded .reportview-container {
  .main {
    overflow: hidden;

    .block-container {
      padding: 0;
    }

    footer {
      display: none;
    }
  }
}
